package com.zlp.partice.aop;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

/**
 * @author zhulaiping
 * @date 2021/6/26-10:56
 */
public class GirlProxy<T> implements InvocationHandler {

    public T girl;
    public GirlProxy(T girl){
        this.girl = girl;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        before();
        Object ret = method.invoke(girl, args);
        after();
        return null;
    }

    public void before(){
        System.out.println("调查背景");
    }

    public void after(){
        System.out.println("询问情况");
    }

    public Object getProxy(){
        return Proxy.newProxyInstance(girl.getClass().getClassLoader(),girl.getClass().getInterfaces(),this);
    }
}
